﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Forget.HRBLL.Model;
using System.Data.SqlClient;
using Forget.Data;

namespace Forget.HRBLL.Logical
{
    public class HolidyInfoLogical
    {
        public static bool AddHolidyInfo(DateTime start, DateTime end, int type, string numberID)
        {
            if (start != DateTime.MinValue && end != DateTime.MinValue)
                return HolidyInfo.AddHolidyInfo(new HolidyInfo() { NumberID = numberID, Start = start, End = end, Type = type });
            return false;
        }

        public static bool DelHolidyInfo(int holidyID)
        {
            if (holidyID > 0)
                return HolidyInfo.DelHolidyInfo(new HolidyInfo() { HolidyID = holidyID });
            return false;
        }

        public static bool AuditHolidyInfo(string numberID, string passIDs,string failIDs)
        {
            if (!string.IsNullOrEmpty(numberID))
                return HolidyInfo.AuditHolidyInfo(numberID, passIDs, failIDs);
            return false;
        }
    }
}

namespace Forget.HRBLL.Model
{
    public partial class HolidyInfo
    {
        private static readonly string AUDITHOLIDYINFO = "HR_Audi_HolidyInfo";

        public static bool AuditHolidyInfo(string numberID, string passIDs,string failIDs)
        {
            SqlParameter[] parms = new SqlParameter[]{
                new SqlParameter(){ SqlDbType= System.Data.SqlDbType.NVarChar, ParameterName="@numberid", Size=20, Value=numberID},
                new SqlParameter(){ SqlDbType= System.Data.SqlDbType.NVarChar, ParameterName="@passids", Size=300, Value=passIDs},
                new SqlParameter(){ SqlDbType= System.Data.SqlDbType.NVarChar, ParameterName="@failids", Size=300, Value=failIDs}
            };
            try
            {
                if (DataAccess.ExecuteNonQuery(System.Data.CommandType.StoredProcedure, AUDITHOLIDYINFO, parms) > 0)
                    return true;
            }
            catch (Exception ex)
            {
                Log.WriteLog("BU.AuditHolidyInfo", ex.Message, ex.StackTrace);                
            }
            return false;
        }
    }
}
